<template>
	<view>
		<view class="login-box">
			<view class="row">
				<u--image width="30rpx" height="40rpx" mode="aspectFit" :src="phoneImage"></u--image>
				<view class="phone-prefix">+86</view>
				<u--input v-model="phone" type="number" fontSize="34rpx" :border="false" placeholder="输入手机号"></u--input>
			</view>
		</view>
		<view class="btn-box">
			<view class="common-btn login-btn" @tap="sendCode">发送验证码</view>
			<view class="flex justify-center">
				<view class="actions">
					<view class="" @tap="check(ModuleEnum.login)">使用密码登录</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import phoneImage from "@/static/login/icon-phone.png"
	import {
		ModuleEnum
	} from "../../config"
	import {
		useCheckModule
	} from "../../hooks/useModule"
	import {
		VerCodeTypeEnum
	} from "@/enums/verCode"
	import {
		pushCode
	} from "@/api/Interface/login"
	export default {
		name: "Logon",
		data() {
			return {
				phoneImage,
				ModuleEnum,
				// phone: "18999999999",
				phone: ""
			}
		},
		methods: {
			check(e) {
				useCheckModule(this, e);
			},
			sendCode() {
				if (!uni.$u.test.mobile(this.phone)) {
					this.$toast("请输入正确的手机号")
					return;
				}
				// uni.navigateTo({
				// 	url: `/pages/password/password?type=${VerCodeTypeEnum['注册']}&phone=${this.phone}`
				// })
				pushCode({
					phone: this.phone,
					flag: VerCodeTypeEnum["注册"]
				}).then(res => {
					if (res.code === 200) {
						uni.navigateTo({
							url: `/pages/password/password?type=${VerCodeTypeEnum['注册']}&phone=${this.phone}`
						})
					}
				})
			}
		},
	}
</script>

<style scoped>
	@import url("../../css/login.css");
</style>
